package com.mmy.service.ship.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mmy.dao.ship.TShipOrderRepository;
import com.mmy.dao.ship.VShipOrderRepository;
import com.mmy.domain.ship.TShipOrder;
import com.mmy.domain.ship.VShipOrder;
import com.mmy.service.ship.TShipOrderService;

@Service
public class TShipOrderServiceImpl implements TShipOrderService {

	@Autowired
	TShipOrderRepository tShipOrderRepository;

	@Autowired
	VShipOrderRepository vShipOrderRepository;

	/**
	 * 获取最大流水号
	 * 
	 * @return 返回值说明 流水号
	 * @author 创建人 dingxd
	 * @date 创建日期 2020.11.17
	 */
	public int getMaxID() {
		// 流水号
		Object objCode = tShipOrderRepository.getMaxID();
		int iID = 0;
		if (objCode != null) {
			iID = Integer.parseInt(objCode.toString());
		}
		return iID;
	}

	/**
	 * 获取订单最大编码
	 * 
	 * @param 参数说明 计划单编码
	 * @return 返回值说明 订单编码
	 * @author 创建人 dingxd
	 * @date 创建日期 2020.11.17
	 */
	public String getMaxCode(int iPlanID) {
		// int 转 string
		String strPlanID = String.valueOf(iPlanID);
		// 返回订单最大编码
		Object objCode = tShipOrderRepository.getMaxCode(strPlanID);
		String strCode = "";
		if (objCode != null) {
			strCode = objCode.toString();
		}
		return strCode;
	}

	/**
	 * 新增id
	 * 
	 * @param
	 * @return
	 */
	public void save(int id) {
		// TODO Auto-generated method stub
		tShipOrderRepository.save(id);
	}

	/**
	 * 新增订单
	 * 
	 * @param
	 * @return
	 */
	public void save(TShipOrder tShipOrder) {
		// TODO Auto-generated method stub
		tShipOrderRepository.save(tShipOrder);
	}

	/**
	 * id查找
	 * 
	 * @param
	 * @return
	 */
	public TShipOrder findByID(int iID) {
		// TODO Auto-generated method stub
		return tShipOrderRepository.findByID(iID);
	}

	/**
	 * id查找
	 * 
	 * @param
	 * @return
	 */
	public List<VShipOrder> findByShipID(int iShipID) {
		// TODO Auto-generated method stub
		return vShipOrderRepository.findByShipID(iShipID);
	}

	/**
	 * 删除预留
	 * 
	 * @param
	 * @return
	 */
	public void delShipOrder(List<Integer> lstID) {
		// TODO Auto-generated method stub
		tShipOrderRepository.delShipOrder(lstID);
	}

	/**
	 * 出纳查询
	 * 
	 * @param
	 * @return
	 */
	public List<VShipOrder> findByCashierAndShipID(String strCashierState, int iShipID) {
		// TODO Auto-generated method stub
		return vShipOrderRepository.findByCashierAndShipID(strCashierState, iShipID);
	}

	/**
	 * 查找全部
	 * 
	 * @param
	 * @return
	 */
	public List<VShipOrder> findAll() {
		// TODO Auto-generated method stub
		return vShipOrderRepository.findAll();
	}

	/**
	 * 会计查询
	 * 
	 * @param
	 * @return
	 */
	public List<VShipOrder> findByAccountAndShipID(String strAccountState, int iShipID) {
		// TODO Auto-generated method stub
		return vShipOrderRepository.findByAccountAndShipID(strAccountState, iShipID);
	}

	public void saveAll(List<TShipOrder> lstCashier) {
		// TODO Auto-generated method stub
		tShipOrderRepository.saveAll(lstCashier);
	}

	/* 个人中心通过登录人获取船票预留 */
	public List<TShipOrder> findByUserID(int userID) {
		// TODO Auto-generated method stub
		// return tShipOrderRepository.findByUserID(userID);
		return null;
	}

	/* 个人中心通过登录人获取船票订单 */
	public List<TShipOrder> findByOrderUserID(int userID) {
		// TODO Auto-generated method stub
		// return tShipOrderRepository.findByOrderUserID(userID);
		return null;
	}

	/* 个人中心通过登录人获取船票退单 */
	public List<TShipOrder> findByChargeBackUserID(int userID) {
		// TODO Auto-generated method stub
		// return tShipOrderRepository.findByChargeBackUserID(userID);
		return null;
	}

}
